package com.suixinsanren.design.responsibilitychain.demo01;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class StAgeCheck extends AbsCheckStudent {

    //获取学生年龄不符合条件的学生对象
    @Override
    public List<Student> checkStudent(List<Student> studentList) {
        List<Student> stAgeIsNotOk = studentList.stream().filter(stu -> {
            Integer age = stu.getAge();
            return Objects.isNull(age) || age <= 0 || age >= 60;
        }).collect(Collectors.toList());
        System.out.println("年龄校验不通过的数据有： = " + stAgeIsNotOk);
        studentList.removeAll(stAgeIsNotOk);
        System.out.println("年龄校验通过的数据有： = " + studentList);
        return studentList;
    }
}
